#nullable enable
using BootstrapBlazor.Components;
using SqlSugar;
using System;
using System.ComponentModel.DataAnnotations;

namespace Application.Core.Entity;

/// <summary>
/// 系统日志实体
/// </summary>
[SugarTable("Logs")]
public class SystemLog
{
    /// <summary>
    /// 主键ID
    /// </summary>
    [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键Id")]
    [Display(Name = "主键")]
    [AutoGenerateColumn(Ignore = true)]
    public int Id { get; set; }

    /// <summary>
    /// 日志级别
    /// </summary>
    [SugarColumn(Length = 20)]
    [Display(Name = "日志级别")]
    [AutoGenerateColumn(Order = 10, Filterable = true, Searchable = true)]
    public string Level { get; set; } = string.Empty;

    /// <summary>
    /// 日志消息
    /// </summary>
    [SugarColumn(Length = 4000)]
    [Display(Name = "日志消息")]
    [AutoGenerateColumn(Order = 20, Filterable = true, Searchable = true)]
    public string Message { get; set; } = string.Empty;

    /// <summary>
    /// 异常信息
    /// </summary>
    [SugarColumn(Length = 4000, IsNullable = true)]
    [Display(Name = "异常信息")]
    [AutoGenerateColumn(Order = 30, Filterable = true, Searchable = true)]
    public string? Exception { get; set; }

    /// <summary>
    /// 调用者名称
    /// </summary>
    [SugarColumn(Length = 40, IsNullable = true)]
    [Display(Name = "调用方法")]
    [AutoGenerateColumn(Order = 50)]
    public string? CallerMemberName { get; set; }

    /// <summary>
    /// 调用文件路径
    /// </summary>
    [SugarColumn(Length = 500, IsNullable = true)]
    [Display(Name = "调用文件路径")]
    [AutoGenerateColumn(Order = 60, Filterable = true, Searchable = true)]
    public string? CallerFilePath { get; set; }

    /// <summary>
    /// 调用行号
    /// </summary>
    [SugarColumn(Length = 10, IsNullable = true)]
    [Display(Name = "调用行号")]
    [AutoGenerateColumn(Order = 70)]
    public int? CallerLineNumber { get; set; }
    
    /// <summary>
    /// 创建时间
    /// </summary>
    [Display(Name = "创建时间")]
    [AutoGenerateColumn(Order = 80, Filterable = true)]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 用户名（如果适用）
    /// </summary>
    [SugarColumn(Length = 50, IsNullable = true)]
    [AutoGenerateColumn(Ignore = true)]
    public string? UserName { get; set; }

    /// <summary>
    /// IP地址
    /// </summary>
    [SugarColumn(Length = 50, IsNullable = true)]
    [AutoGenerateColumn(Ignore = true)]
    public string? IpAddress { get; set; }

    /// <summary>
    /// 模块名称
    /// </summary>
    [SugarColumn(Length = 100, IsNullable = true)]
    [Display(Name = "模块名称")]
    [AutoGenerateColumn(Ignore = true)]
    public string? Module { get; set; }
}